package com.yihaodian.search.code.service.impl;

import com.yihaodian.api.client.SearchClient;
import com.yihaodian.api.search.SugRequest;
import com.yihaodian.api.search.SugResponse;
import com.yihaodian.search.code.service.SourceIndexService;
import com.yihaodian.search.code.service.SuggestService;

public class SuggestServiceImpl implements SuggestService{
	SearchClient client = new SearchClient();
	
	@Override
	public SugResponse getSuggest(String keyword) {
		SugRequest request = new SugRequest();
		request.setIndexName(SourceIndexService.INDEX_NAME);
		request.setField("fileName");
		request.setKey(keyword);
		request.setNumber(5);
		SugResponse resp = client.suggest(request);
		
		request.setField("content");
		SugResponse resp2 = client.suggest(request);
		
		resp.getResult().addAll(resp2.getResult());
		
		return resp;
	}
}
